﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace FrogEngine
{
	public class FirstPersonChaseCamera : BaseCamera
	{
		public FirstPersonChaseCamera(IEngine engine, IOriented3DGameEntity entity, float mass)
			: base(engine)
		{
			this.entityToFollow = entity;
			this.Position = entity.Position;
			this.Forward = entity.Forward;
			this.Right = entity.Right;
			this.Up = entity.Up;
			this.Mass = mass;
			this.NearPlane = 1;
			this.FarPlane = 100000;
			this.AspectRatio = engine.GraphicsDevice.DisplayMode.AspectRatio;
		}

		private IOriented3DGameEntity entityToFollow;

		public override void Update(GameTime gameTime)
		{
			float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds;

			this.Position = entityToFollow.Position;
			this.Velocity = entityToFollow.Velocity;
			this.Forward = entityToFollow.Forward;
			this.Right = entityToFollow.Right;
			this.Up = entityToFollow.Up;
			this.World = entityToFollow.World;

			this.View = Matrix.CreateLookAt(Position, Position + Forward, Up);
			this.Projection = Matrix.CreatePerspectiveFieldOfView(Fov, AspectRatio, NearPlane, FarPlane);
		}
	}
}
